#include <stdio.h>

#include "libpbd.h"

int main(int argc, char *argv[])
{
	pbd_handle_t *h;
	unsigned char *pkt;
	int size, i;

	unsigned char sha[6] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
	unsigned char tha[6] = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15 };
	unsigned char sip[4] = { 192, 222, 1, 45 };
	unsigned char tip[4] = { 192, 44, 2, 1};

	if (argc == 2)
		h = libpbd_init(argv[1]);
	else
		h = libpbd_init(NULL);
	if (!h) {
		printf("Create PBD Handle Fail\n");
		return 0;
	}

	pbd_auto_build_arp(h, 1, sha, sip, tha, tip);
	pbd_auto_build_ether(h, tha, 0x0806);
	pbd_auto_build_ether(h, tha, 0x0806);

	pkt = libpbd_to_packet(h, &size);

	printf("Create Packet: [%d bytes]\n  ", size);
	for (i = 1; i <= size; i++) {
		printf("%02x ", pkt[i - 1]);
		if(i % 10 == 0)
			printf("\n  ");
	}
	printf("\n");
		
	libpbd_destroy(h);
	return 0;
}
